/**
 * 
 */
requirejs.config({
    baseUrl:'http://static.auoffice.com/static/js' ,
    waitSeconds: 0,
    paths: {
    	jquery:'libs/jquery.min',
        //plugins
        base: 'common/base',
    }
});

require([
    'jquery',
 	'common/base',
],function($,base) {
      $('.login').click(function(event) {
        event.preventDefault();
        var email = $("[data-id=email]").val().replace(/(^\s*)|(\s*$)/g, "");
        var password = $("[name=password]").val().replace(/(^\s*)|(\s*$)/g, "");
        if (email == ""){
        	$("#post-error").html("请输入用户名");
        	return;
        }
        if (password == ""){
        	$("#post-error").html("请输入密码");
        	return;
        }
        base.services.post('account', 'login', {"email":email,"password":password}, function(code, msg, data) {
        	if (code === base.services.CODE_SUCC) {
        		window.location.href=data.next;
        	} else {
        		$("#post-error").html(msg);
        	}
        });
    });
    document.onkeydown=function(event){
		var e = event || window.event || arguments.callee.caller.arguments[0];
		if(e && (e.keyCode==13))
		{
			$('.login').click();
		}
	};
});